package com.eliaukjq.xunlianying;

import java.util.HashMap;
import java.util.Map;

public class EmployeeSalary {
    public static void main(String[] args) {
        // 创建 HashMap 实例
        Map<String, Integer> salaryMap = new HashMap<>();

        // 添加员工及其薪水
        salaryMap.put("Alice", 70000);
        salaryMap.put("Bob", 55000);
        salaryMap.put("Charlie", 120000);

        // 打印所有员工及其薪水
        System.out.println("Employees and their salaries:");
        for (Map.Entry<String, Integer> entry : salaryMap.entrySet()) {
            System.out.println(entry.getKey() + ": $" + entry.getValue());
        }

        // 获取特定员工的薪水
        String name = "Alice";
        if (salaryMap.containsKey(name)) {
            System.out.println(name + "'s Salary: $" + salaryMap.get(name));
        } else {
            System.out.println("Employee not found.");
        }

        // 更新员工薪水
        salaryMap.put("Alice", 75000);
        System.out.println("Updated Alice's Salary: $" + salaryMap.get("Alice"));

        // 删除员工记录
        salaryMap.remove("Bob");
        System.out.println("Bob's record removed. Current records:");
        for (String key : salaryMap.keySet()) {
            System.out.println(key + ": $" + salaryMap.get(key));
        }
    }
}
